package com.zhu.service.util.handler;

import com.zhu.model.pojo.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data

@NoArgsConstructor
public class BusinessException extends RuntimeException{
    private Integer code;
    private String msg;


    public BusinessException(String msg){
        this.msg=msg;
    }

    public BusinessException(Integer code,String msg){
        this.msg=msg;
        this.code=code;
    }

    public BusinessException(String msg,Throwable cause){
        super(cause);
        this.msg=msg;
    }

    public BusinessException(Integer code,String msg,Throwable cause){
        super(cause);
        this.msg=msg;
        this.code=code;
    }

    public BusinessException(ResultCodeEnum resultCodeEnum){
        this.msg=resultCodeEnum.getMessage();
        this.code=resultCodeEnum.getCode();
    }

    public BusinessException(ResultCodeEnum resultCodeEnum,Throwable cause){
        super(cause);
        this.msg=resultCodeEnum.getMessage();
        this.code=resultCodeEnum.getCode();
    }


}
